home *** CD-ROM | disk | FTP | other *** search
/ Champak 50 / Volume 50 - JOGO DISK .iso / Games / moonstonemadness.swf / scripts / __Packages / TakGround.as < prev    next >
Text File  |  2007-09-27  |  28KB  |  830 lines

  1. class TakGround extends SideScroller.MovingObject
  2. {
  3.    static var BOAR_SOUNDS = ["Boar_Sound_01.mp3","Boar_Sound_02.mp3","Boar_Sound_03.mp3","Boar_Sound_04.mp3","Boar_Sound_05.mp3","Boar_Sound_06.mp3","Boar_Sound_07.mp3","Boar_Sound_08.mp3","Boar_Sound_09.mp3","Boar_Sound_10.mp3","Boar_Sound_11.mp3"];
  4.    static var BOAR_STEP_SOUNDS = ["Boar_Step_01.mp3","Boar_Step_02.mp3","Boar_Step_03.mp3","Boar_Step_04.mp3","Boar_Step_05.mp3","Boar_Step_06.mp3","Boar_Step_07.mp3","Boar_Step_08.mp3","Boar_Step_09.mp3"];
  5.    static var SMOKE_DELAY = 3;
  6.    static var SMOKE_RANDOM = 3;
  7.    static var CROUCH_SPEED = 8;
  8.    static var CRUISE_CONTROL_SPEED = 9;
  9.    static var SLOW_DOWN_SPEED = 4;
  10.    static var RUN_SPEED = 14;
  11.    static var SPEED_CHANGE = 1.2;
  12.    static var MIN_SPEED_AIR = 4;
  13.    static var MAX_SPEED_AIR = 11;
  14.    static var MOY_SPEED_AIR = 8;
  15.    static var ACCELERATION_AIR = 0.25;
  16.    static var DIRECTION_CHANGE_FACTOR_AIR = 0.85;
  17.    static var JUMPSPEED = 14;
  18.    static var STUNNED_TIME = 22;
  19.    static var EASTER_EGG_KEY = "E";
  20.    static var BOAR_SOUND_KEY = "B";
  21.    static var CAMERA_GAP_SPEED_CHANGE = 1.5;
  22.    static var CAMERA_GAP_SPEED_CHANGE_FAST = 3.5;
  23.    static var nPEPPER_REACTION_TIME = 90;
  24.    static var nPEPPER_FLASH_INTERVAL = 3;
  25.    static var nINVINCINBLE_SPEED_MOD = 1.5;
  26.    static var nMINIMUM_DELAY_MS_LOST = 90;
  27.    function TakGround(__mcRef, __oLayer)
  28.    {
  29.       super(__mcRef,__oLayer);
  30.       TakGround.oCtrl = this;
  31.       this.bReactToCollisions = !Main.__get__Instance().__get__CodeBoxManager().__get__Invincible();
  32.       this.bGoingLeft = false;
  33.       this.bGoingRight = false;
  34.       this.nMSLostTimer = 0;
  35.       this.bCrouched = false;
  36.       this.bEasterEgg = false;
  37.       this.aEEObj = new Array();
  38.       this.bReachedEnd = false;
  39.       this.nSmokeDelay = TakGround.SMOKE_DELAY;
  40.       this.oKeysManager = new Library.Utils.KeysManager();
  41.       this.oKeysManager.setListenerForKey(this,String(TakGround.EASTER_EGG_KEY).charCodeAt(0));
  42.       this.oKeysManager.setListenerForKey(this,String(TakGround.BOAR_SOUND_KEY).charCodeAt(0));
  43.       this.oKeysManager.setListenerForKey(this,38);
  44.       this.oKeysManager.setListenerForKey(this,40);
  45.       this.oKeysManager.setListenerForKey(this,37);
  46.       this.oKeysManager.setListenerForKey(this,39);
  47.       this.oKeysManager.setListenerForKey(this,32);
  48.       this.setState("CruiseControl");
  49.    }
  50.    static function get Instance()
  51.    {
  52.       return TakGround.oCtrl;
  53.    }
  54.    function doBoarSound()
  55.    {
  56.       if(Library.Sound.SoundManager.__get__SoundsQty() <= 6)
  57.       {
  58.          var _loc2_ = Library.Utils.MoreMath.getRandomRange(0,TakGround.BOAR_SOUNDS.length - 1);
  59.          var _loc3_ = TakGround.BOAR_SOUNDS[_loc2_];
  60.          this.oBoarSound.doStop();
  61.          this.oBoarSound = Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,_loc3_,180,1);
  62.       }
  63.    }
  64.    function doBoarStepSound()
  65.    {
  66.       if(Library.Sound.SoundManager.__get__SoundsQty() <= 6)
  67.       {
  68.          var _loc2_ = Library.Utils.MoreMath.getRandomRange(0,TakGround.BOAR_STEP_SOUNDS.length - 1);
  69.          var _loc3_ = TakGround.BOAR_STEP_SOUNDS[_loc2_];
  70.          this.oBoarStepSound.doStop();
  71.          this.oBoarStepSound = Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,_loc3_);
  72.       }
  73.    }
  74.    function doEnterFrame()
  75.    {
  76.       super.doEnterFrame();
  77.       this.nMSLostTimer = this.nMSLostTimer - 1;
  78.       if(this.bPepperReaction)
  79.       {
  80.          this.nPepperColor = this.nPepperColor - 1;
  81.          if(this.nPepperColor <= 0)
  82.          {
  83.             this.bPepperColorActive = !this.bPepperColorActive;
  84.             this.nPepperColor = TakGround.nPEPPER_FLASH_INTERVAL;
  85.             if(this.bPepperColorActive)
  86.             {
  87.                var _loc4_ = [1.68562018483454,0.129222856217665,-1.06484304105221,0,-29.125,-0.506833163112779,1.05012620416499,0.206706958947793,0,-29.125,0.46966683688722,-1.37227714378233,1.65261030689511,0,-29.125,0,0,0,1,0];
  88.                var _loc5_ = new flash.filters.ColorMatrixFilter(_loc4_);
  89.                this.mcRef.filters = [_loc5_];
  90.             }
  91.             else
  92.             {
  93.                this.mcRef.filters = [];
  94.             }
  95.          }
  96.       }
  97.       for(var _loc3_ in this.aEEObj)
  98.       {
  99.          if(this.aEEObj[_loc3_]._currentframe == undefined)
  100.          {
  101.             this.aEEObj.splice(Number(_loc3_),1);
  102.          }
  103.       }
  104.    }
  105.    function doPause()
  106.    {
  107.       super.doPause();
  108.       this.oStunnedSound.doPause();
  109.       this.oPepperLoopSound.doPause();
  110.       this.oPepperStartSound.doPause();
  111.       for(var _loc4_ in this.aEEObj)
  112.       {
  113.          for(var _loc3_ in this.aEEObj[_loc4_])
  114.          {
  115.             this.aEEObj[_loc4_][_loc3_].stop();
  116.          }
  117.       }
  118.    }
  119.    function doResume()
  120.    {
  121.       super.doResume();
  122.       this.oStunnedSound.doResume();
  123.       this.oPepperLoopSound.doResume();
  124.       this.oPepperStartSound.doResume();
  125.       for(var _loc4_ in this.aEEObj)
  126.       {
  127.          for(var _loc3_ in this.aEEObj[_loc4_])
  128.          {
  129.             this.aEEObj[_loc4_][_loc3_].play();
  130.          }
  131.       }
  132.       if(this.mcRef.mcHeadSwing.mcAnim._currentframe == 1)
  133.       {
  134.          this.mcRef.mcHeadSwing.mcAnim.stop();
  135.       }
  136.       var _loc5_ = true;
  137.       if(this.__get__CurrentState().indexOf("Stunned") != -1)
  138.       {
  139.          _loc5_ = false;
  140.       }
  141.       else if(this.__get__CurrentState().indexOf("Feather") != -1)
  142.       {
  143.          _loc5_ = false;
  144.       }
  145.       else if(this.__get__CurrentState().indexOf("Jump") != -1)
  146.       {
  147.          _loc5_ = false;
  148.       }
  149.       this.bGoingLeft = this.oKeysManager.isKeyDown(37);
  150.       this.bGoingRight = this.oKeysManager.isKeyDown(39);
  151.       this.bNeedToCrouch = this.oKeysManager.isKeyDown(40);
  152.       this.bCrouched = this.bNeedToCrouch;
  153.       if(_loc5_)
  154.       {
  155.          this.doUnlockState();
  156.          if(!this.bCrouched)
  157.          {
  158.             if(!this.bPepperReaction)
  159.             {
  160.                if(this.bGoingLeft)
  161.                {
  162.                   this.setState("SlowDown");
  163.                }
  164.                else if(this.bGoingRight)
  165.                {
  166.                   this.setState("Run");
  167.                }
  168.                else
  169.                {
  170.                   this.setState("CruiseControl");
  171.                }
  172.             }
  173.             else
  174.             {
  175.                this.setState("Run");
  176.             }
  177.          }
  178.          else
  179.          {
  180.             this.setState("CrouchRun");
  181.          }
  182.       }
  183.    }
  184.    function doSoundEvent(__nEvent, __oSound)
  185.    {
  186.       if(__nEvent === Library.Sound.SoundManager.EVENT_SOUND_COMPLETE)
  187.       {
  188.          if(__oSound == this.oStunnedSound)
  189.          {
  190.             delete this.oStunnedSound;
  191.          }
  192.          if(__oSound == this.oPepperLoopSound)
  193.          {
  194.             delete this.oPepperLoopSound;
  195.          }
  196.          if(__oSound == this.oPepperStartSound)
  197.          {
  198.             delete this.oPepperStartSound;
  199.             this.oPepperLoopSound = Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"PimentActive.wav",100,9999);
  200.          }
  201.       }
  202.    }
  203.    function onKeyManagerEvent(__nEvent, __nCode)
  204.    {
  205.       if(!this.__get__Paused())
  206.       {
  207.          switch(__nEvent)
  208.          {
  209.             case Library.Utils.KeysManager.EVENT_KEY_DOWN:
  210.                switch(__nCode)
  211.                {
  212.                   case String(TakGround.EASTER_EGG_KEY).charCodeAt(0):
  213.                      this.onToggleEE();
  214.                      break;
  215.                   case String(TakGround.BOAR_SOUND_KEY).charCodeAt(0):
  216.                      this.doBoarSound();
  217.                      break;
  218.                   case 37:
  219.                      this.bGoingLeft = true;
  220.                      if(!this.bPepperReaction)
  221.                      {
  222.                         if(!this.bCrouched)
  223.                         {
  224.                            this.setState("SlowDown");
  225.                         }
  226.                         else
  227.                         {
  228.                            this.setState("CrouchRun");
  229.                         }
  230.                      }
  231.                      break;
  232.                   case 39:
  233.                      this.bGoingRight = true;
  234.                      if(!this.bPepperReaction)
  235.                      {
  236.                         if(!this.bCrouched)
  237.                         {
  238.                            this.setState("Run");
  239.                         }
  240.                         else
  241.                         {
  242.                            this.setState("CrouchRun");
  243.                         }
  244.                      }
  245.                      break;
  246.                   case 40:
  247.                      this.setState("CrouchRun");
  248.                      this.bNeedToCrouch = true;
  249.                      break;
  250.                   case 38:
  251.                      if(!this.bCrouched)
  252.                      {
  253.                         this.setState("JumpStart");
  254.                      }
  255.                      break;
  256.                   case 32:
  257.                      if(this.mcRef.mcHeadSwing != undefined)
  258.                      {
  259.                         if(this.mcRef.mcHeadSwing.mcAnim._currentframe == 1)
  260.                         {
  261.                            this.mcRef.mcHeadSwing.mcAnim.play();
  262.                            var _loc3_ = Library.Utils.MoreMath.getRandomRange(1,3);
  263.                            var _loc2_ = "new_boar_head_swing-0" + _loc3_ + ".mp3";
  264.                            Library.Sound.SoundManager.isSoundPlaying("new_boar_head_swing-01.mp3").oSound.doStop();
  265.                            Library.Sound.SoundManager.isSoundPlaying("new_boar_head_swing-02.mp3").oSound.doStop();
  266.                            Library.Sound.SoundManager.isSoundPlaying("new_boar_head_swing-03.mp3").oSound.doStop();
  267.                            Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,_loc2_);
  268.                         }
  269.                      }
  270.                }
  271.                break;
  272.             case Library.Utils.KeysManager.EVENT_KEY_UP:
  273.                switch(__nCode)
  274.                {
  275.                   case 37:
  276.                      this.bGoingLeft = false;
  277.                      if(!this.bPepperReaction)
  278.                      {
  279.                         if(this.bGoingRight)
  280.                         {
  281.                            if(!this.bCrouched)
  282.                            {
  283.                               this.setState("Run");
  284.                            }
  285.                            else
  286.                            {
  287.                               this.setState("CrouchRun");
  288.                            }
  289.                         }
  290.                         else if(!this.bCrouched)
  291.                         {
  292.                            this.setState("CruiseControl");
  293.                         }
  294.                         else
  295.                         {
  296.                            this.setState("CrouchRun");
  297.                         }
  298.                      }
  299.                      break;
  300.                   case 39:
  301.                      this.bGoingRight = false;
  302.                      if(!this.bPepperReaction)
  303.                      {
  304.                         if(this.bGoingLeft)
  305.                         {
  306.                            if(!this.bCrouched)
  307.                            {
  308.                               this.setState("SlowDown");
  309.                            }
  310.                            else
  311.                            {
  312.                               this.setState("CrouchRun");
  313.                            }
  314.                         }
  315.                         else if(!this.bCrouched)
  316.                         {
  317.                            this.setState("CruiseControl");
  318.                         }
  319.                         else
  320.                         {
  321.                            this.setState("CrouchRun");
  322.                         }
  323.                      }
  324.                      break;
  325.                   case 40:
  326.                      if(!this.bPepperReaction)
  327.                      {
  328.                         if(this.bGoingLeft)
  329.                         {
  330.                            this.setState("SlowDown");
  331.                         }
  332.                         else if(this.bGoingRight)
  333.                         {
  334.                            this.setState("Run");
  335.                         }
  336.                         else
  337.                         {
  338.                            this.setState("CruiseControl");
  339.                         }
  340.                      }
  341.                      else
  342.                      {
  343.                         this.setState("Run");
  344.                      }
  345.                      this.bNeedToCrouch = false;
  346.                }
  347.          }
  348.       }
  349.    }
  350.    function onHitSpecial(__oRef)
  351.    {
  352.       if(__oRef instanceof MiniStone)
  353.       {
  354.          Game.__get__Instance().onCatchMiniStone();
  355.       }
  356.       else if(__oRef instanceof MoonStone)
  357.       {
  358.          Game.__get__Instance().onCatchMoonstone();
  359.       }
  360.       else if(__oRef instanceof Feather)
  361.       {
  362.          this.doForcedSetState("FeatherCatch");
  363.          this.doLockState();
  364.       }
  365.       else if(__oRef instanceof Pepper)
  366.       {
  367.          this.doPepperReaction();
  368.       }
  369.       else if(__oRef instanceof EndTrigger)
  370.       {
  371.          if(!this.bReachedEnd)
  372.          {
  373.             LevelManager.__get__Instance().onTakReachEnd();
  374.             this.bReachedEnd = true;
  375.          }
  376.       }
  377.    }
  378.    function onBackFromMiniGame()
  379.    {
  380.       this.doForcedSetState("FeatherBackOnEarth");
  381.    }
  382.    function doReactCollision()
  383.    {
  384.       if(!Main.__get__Instance().__get__CodeBoxManager().__get__Invincible())
  385.       {
  386.          this.doForcedSetState("StunnedStart");
  387.          this.doLockState();
  388.          if(Game.__get__Instance().__get__MSQty() > 0 && this.nMSLostTimer <= 0)
  389.          {
  390.             var _loc3_ = this.oLayer.doAttachVisual("mcMoonStoneLost");
  391.             _loc3_._x = this.mcRef._x;
  392.             _loc3_._y = this.mcRef._y;
  393.             var _loc4_ = new MSLost(_loc3_,this.oLayer);
  394.             this.nMSLostTimer = TakGround.nMINIMUM_DELAY_MS_LOST;
  395.             Game.__get__Instance().onLostMoonstone();
  396.          }
  397.          super.doReactCollision();
  398.       }
  399.       else
  400.       {
  401.          Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"ItemHit.mp3");
  402.       }
  403.    }
  404.    function doSetEEOn(__mc)
  405.    {
  406.       if(!Library.Utils.Tools.isItemInArray(this.aEEObj,__mc))
  407.       {
  408.          this.aEEObj.push(__mc);
  409.       }
  410.       __mc.gotoAndStop(this.__get__EeLabel());
  411.    }
  412.    function doDestroy()
  413.    {
  414.       delete this.oBoarSound;
  415.       delete this.oBoarStepSound;
  416.       delete this.aEEObj;
  417.       this.oKeysManager.doDestroy();
  418.       delete this.oKeysManager;
  419.       this.oStunnedSound.doDestroy();
  420.       delete this.oStunnedSound;
  421.       delete TakGround.oCtrl;
  422.       super.doDestroy();
  423.    }
  424.    function get EeLabel()
  425.    {
  426.       var _loc2_ = "Male";
  427.       if(this.bEasterEgg)
  428.       {
  429.          _loc2_ = "Female";
  430.       }
  431.       return _loc2_;
  432.    }
  433.    function get IsInHeadSwing()
  434.    {
  435.       var _loc2_ = undefined;
  436.       if(this.mcRef.mcHeadSwing.mcAnim._currentframe == undefined)
  437.       {
  438.          _loc2_ = false;
  439.       }
  440.       else
  441.       {
  442.          _loc2_ = this.mcRef.mcHeadSwing.mcAnim._currentframe != 1;
  443.       }
  444.       return _loc2_;
  445.    }
  446.    function doFeatherBackOnEarth()
  447.    {
  448.       if(this.isStateComplete())
  449.       {
  450.          this.doUnlockState();
  451.          this.bCrouched = false;
  452.          if(!this.bPepperReaction)
  453.          {
  454.             this.setState("CruiseControl");
  455.          }
  456.          else
  457.          {
  458.             this.setState("Run");
  459.          }
  460.       }
  461.       this.doNormalizeCameraGap(TakGround.CAMERA_GAP_SPEED_CHANGE);
  462.       this.nSpeedX = 0;
  463.    }
  464.    function doFeatherNoTak()
  465.    {
  466.       this.doSetSpeeds(undefined,-1,true);
  467.    }
  468.    function doFeatherCatch()
  469.    {
  470.       this.mcRef._rotation = 0;
  471.       if(this.isStateComplete())
  472.       {
  473.          this.doForcedSetState("FeatherNoTak");
  474.          Game.__get__Instance().onFeatherCatch();
  475.       }
  476.       this.doSetSpeeds(undefined,-1,true);
  477.       this.doNormalizeCameraGap(TakGround.CAMERA_GAP_SPEED_CHANGE);
  478.    }
  479.    function doJumpLoop()
  480.    {
  481.       this.doJumpMove();
  482.    }
  483.    function doJumpStart()
  484.    {
  485.       if(this.isStateComplete())
  486.       {
  487.          this.doForcedSetState("JumpLoop");
  488.       }
  489.       this.doJumpMove();
  490.    }
  491.    function doCrouchRun()
  492.    {
  493.       var _loc2_ = undefined;
  494.       if(this.bPepperReaction)
  495.       {
  496.          _loc2_ = TakGround.RUN_SPEED;
  497.       }
  498.       else
  499.       {
  500.          _loc2_ = TakGround.CROUCH_SPEED;
  501.       }
  502.       if(Main.__get__Instance().__get__CodeBoxManager().__get__Invincible())
  503.       {
  504.          _loc2_ *= TakGround.nINVINCINBLE_SPEED_MOD;
  505.       }
  506.       this.nSpeedX = Library.Utils.MoreMath.getReachNum(this.nSpeedX,_loc2_,TakGround.SPEED_CHANGE);
  507.       this.doAddSmoke();
  508.       this.doNormalizeCameraGap(TakGround.CAMERA_GAP_SPEED_CHANGE);
  509.    }
  510.    function doCruiseControl()
  511.    {
  512.       var _loc2_ = TakGround.CRUISE_CONTROL_SPEED;
  513.       if(Main.__get__Instance().__get__CodeBoxManager().__get__Invincible())
  514.       {
  515.          _loc2_ *= TakGround.nINVINCINBLE_SPEED_MOD;
  516.       }
  517.       this.nSpeedX = Library.Utils.MoreMath.getReachNum(this.nSpeedX,_loc2_,TakGround.SPEED_CHANGE);
  518.       this.doAddSmoke();
  519.       this.doNormalizeCameraGap(TakGround.CAMERA_GAP_SPEED_CHANGE);
  520.    }
  521.    function doRun()
  522.    {
  523.       if(this.bPepperReaction)
  524.       {
  525.          this.nPepperTimer = this.nPepperTimer - 1;
  526.          if(this.nPepperTimer <= 0)
  527.          {
  528.             this.bPepperReaction = false;
  529.             this.mcRef.filters = [];
  530.             this.oPepperLoopSound.doFadeTo(0);
  531.             if(!this.bGoingRight)
  532.             {
  533.                if(this.bGoingLeft)
  534.                {
  535.                   this.setState("SlowDown");
  536.                }
  537.                else
  538.                {
  539.                   this.setState("CruiseControl");
  540.                }
  541.             }
  542.          }
  543.       }
  544.       var _loc2_ = TakGround.RUN_SPEED;
  545.       if(Main.__get__Instance().__get__CodeBoxManager().__get__Invincible())
  546.       {
  547.          _loc2_ *= TakGround.nINVINCINBLE_SPEED_MOD;
  548.       }
  549.       this.nSpeedX = Library.Utils.MoreMath.getReachNum(this.nSpeedX,_loc2_,TakGround.SPEED_CHANGE);
  550.       this.doAddSmoke();
  551.       this.doEnlargeCameraGap(TakGround.CAMERA_GAP_SPEED_CHANGE_FAST);
  552.    }
  553.    function doSlowDown()
  554.    {
  555.       this.nSpeedX = Library.Utils.MoreMath.getReachNum(this.nSpeedX,TakGround.SLOW_DOWN_SPEED,TakGround.SPEED_CHANGE);
  556.       this.doAddSmoke();
  557.       this.doReduceCameraGap(TakGround.CAMERA_GAP_SPEED_CHANGE_FAST);
  558.    }
  559.    function doStunnedEnd()
  560.    {
  561.       if(this.isStateComplete())
  562.       {
  563.          this.doUnlockState();
  564.          if(!this.bNeedToCrouch)
  565.          {
  566.             if(!this.bPepperReaction)
  567.             {
  568.                if(this.bGoingLeft)
  569.                {
  570.                   this.setState("SlowDown");
  571.                }
  572.                else if(this.bGoingRight)
  573.                {
  574.                   this.setState("Run");
  575.                }
  576.                else
  577.                {
  578.                   this.setState("CruiseControl");
  579.                }
  580.             }
  581.             else
  582.             {
  583.                this.setState("Run");
  584.             }
  585.          }
  586.          else
  587.          {
  588.             this.setState("CrouchRun");
  589.          }
  590.       }
  591.       this.doNormalizeCameraGap(3);
  592.    }
  593.    function doStunnedStart()
  594.    {
  595.       if(this.isStateComplete())
  596.       {
  597.          this.nStunnedTime = TakGround.STUNNED_TIME;
  598.          this.doForcedSetState("StunnedLoop");
  599.       }
  600.       this.doNormalizeCameraGap(TakGround.CAMERA_GAP_SPEED_CHANGE);
  601.    }
  602.    function doStunnedLoop()
  603.    {
  604.       this.nSpeedX = Library.Utils.MoreMath.getReachZero(this.nSpeedX,2.5);
  605.       if(this.nStunnedTime > 0)
  606.       {
  607.          this.nStunnedTime = this.nStunnedTime - 1;
  608.       }
  609.       else
  610.       {
  611.          this.doForcedSetState("StunnedEnd");
  612.       }
  613.       this.doNormalizeCameraGap(TakGround.CAMERA_GAP_SPEED_CHANGE);
  614.    }
  615.    function doPepperReaction()
  616.    {
  617.       this.nPepperTimer = TakGround.nPEPPER_REACTION_TIME;
  618.       this.bPepperReaction = true;
  619.       if(!this.bCrouched)
  620.       {
  621.          this.setState("Run");
  622.       }
  623.       else
  624.       {
  625.          this.setState("CrouchRun");
  626.       }
  627.       this.oPepperStartSound.doStop();
  628.       delete this.oPepperStartSound;
  629.       this.oPepperLoopSound.doStop();
  630.       delete this.oPepperLoopSound;
  631.       this.oPepperStartSound = Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"CatchPiment.mp3");
  632.       this.oPepperStartSound.doAddListener(this);
  633.       this.bPepperColorActive = false;
  634.       this.nPepperColor = TakGround.nPEPPER_FLASH_INTERVAL;
  635.    }
  636.    function onToggleEE()
  637.    {
  638.       this.bEasterEgg = !this.bEasterEgg;
  639.       for(var _loc2_ in this.aEEObj)
  640.       {
  641.          this.aEEObj[_loc2_].gotoAndStop(this.__get__EeLabel());
  642.       }
  643.       this.doBoarSound();
  644.    }
  645.    function doNormalizeCameraGap(__nChange)
  646.    {
  647.       if(SideScroller.SideScrollerManager.__get__Instance().__get__CameraManager().__get__FollowAddonX() > 0)
  648.       {
  649.          SideScroller.SideScrollerManager.__get__Instance().__get__CameraManager().FollowAddonX = SideScroller.SideScrollerManager.__get__Instance().__get__CameraManager().FollowAddonX - __nChange;
  650.          if(SideScroller.SideScrollerManager.__get__Instance().__get__CameraManager().__get__FollowAddonX() < 0)
  651.          {
  652.             SideScroller.SideScrollerManager.__get__Instance().__get__CameraManager().__set__FollowAddonX(0);
  653.          }
  654.       }
  655.       else if(SideScroller.SideScrollerManager.__get__Instance().__get__CameraManager().__get__FollowAddonX() < 0)
  656.       {
  657.          SideScroller.SideScrollerManager.__get__Instance().__get__CameraManager().FollowAddonX = SideScroller.SideScrollerManager.__get__Instance().__get__CameraManager().FollowAddonX + __nChange;
  658.          if(SideScroller.SideScrollerManager.__get__Instance().__get__CameraManager().__get__FollowAddonX() > 0)
  659.          {
  660.             SideScroller.SideScrollerManager.__get__Instance().__get__CameraManager().__set__FollowAddonX(0);
  661.          }
  662.       }
  663.    }
  664.    function doReduceCameraGap(__nChange)
  665.    {
  666.       if(SideScroller.SideScrollerManager.__get__Instance().__get__CameraManager().__get__FollowAddonX() > -100)
  667.       {
  668.          SideScroller.SideScrollerManager.__get__Instance().__get__CameraManager().FollowAddonX = SideScroller.SideScrollerManager.__get__Instance().__get__CameraManager().FollowAddonX - __nChange;
  669.       }
  670.    }
  671.    function doEnlargeCameraGap(__nChange)
  672.    {
  673.       if(SideScroller.SideScrollerManager.__get__Instance().__get__CameraManager().__get__FollowAddonX() < 175)
  674.       {
  675.          SideScroller.SideScrollerManager.__get__Instance().__get__CameraManager().FollowAddonX = SideScroller.SideScrollerManager.__get__Instance().__get__CameraManager().FollowAddonX + __nChange;
  676.       }
  677.    }
  678.    function doAddSmoke()
  679.    {
  680.       if(this.nSmokeDelay == 0)
  681.       {
  682.          this.nSmokeDelay = TakGround.SMOKE_DELAY;
  683.          var _loc3_ = undefined;
  684.          if(Main.__get__Instance().__get__CodeBoxManager().__get__Invincible())
  685.          {
  686.             _loc3_ = "Dynamic_TrailStar";
  687.          }
  688.          else
  689.          {
  690.             _loc3_ = "Dynamic_TrailSmoke";
  691.          }
  692.          var _loc2_ = this.__get__ParentLayer().doAttachVisual(_loc3_);
  693.          _loc2_._x = this.__get__Ref()._x + Library.Utils.MoreMath.getRandomRange(- TakGround.SMOKE_RANDOM,TakGround.SMOKE_RANDOM);
  694.          _loc2_._y = this.__get__Ref()._y + Library.Utils.MoreMath.getRandomRange(- TakGround.SMOKE_RANDOM,TakGround.SMOKE_RANDOM);
  695.          var _loc4_ = new TrailSmoke(_loc2_,this.__get__ParentLayer());
  696.       }
  697.       else
  698.       {
  699.          this.nSmokeDelay = this.nSmokeDelay - 1;
  700.       }
  701.    }
  702.    function doJumpMove()
  703.    {
  704.       if(this.bGoingRight || this.bPepperReaction)
  705.       {
  706.          if(this.nSpeedX < 0)
  707.          {
  708.             this.nSpeedX *= TakGround.DIRECTION_CHANGE_FACTOR_AIR;
  709.          }
  710.          var _loc2_ = TakGround.MAX_SPEED_AIR;
  711.          if(Main.__get__Instance().__get__CodeBoxManager().__get__Invincible())
  712.          {
  713.             _loc2_ *= TakGround.nINVINCINBLE_SPEED_MOD;
  714.          }
  715.          if(this.nSpeedX < _loc2_)
  716.          {
  717.             this.doSetSpeeds(TakGround.ACCELERATION_AIR,undefined,true);
  718.          }
  719.          else
  720.          {
  721.             this.nSpeedX = TakGround.MAX_SPEED_AIR;
  722.          }
  723.       }
  724.       else if(this.bGoingLeft)
  725.       {
  726.          if(this.nSpeedX > 0)
  727.          {
  728.             this.nSpeedX *= TakGround.DIRECTION_CHANGE_FACTOR_AIR;
  729.          }
  730.          if(this.nSpeedX > TakGround.MIN_SPEED_AIR)
  731.          {
  732.             this.doSetSpeeds(- TakGround.ACCELERATION_AIR,undefined,true);
  733.          }
  734.          else
  735.          {
  736.             this.nSpeedX = TakGround.MIN_SPEED_AIR;
  737.          }
  738.       }
  739.       else
  740.       {
  741.          this.nSpeedX = Library.Utils.MoreMath.getReachNum(this.nSpeedX,TakGround.MOY_SPEED_AIR,TakGround.ACCELERATION_AIR);
  742.       }
  743.       if(Main.__get__Instance().__get__CodeBoxManager().__get__Invincible())
  744.       {
  745.          this.doAddSmoke();
  746.       }
  747.    }
  748.    function onHitGround()
  749.    {
  750.       if(this.__get__CurrentState() == "JumpStart" || this.__get__CurrentState() == "JumpLoop")
  751.       {
  752.          this.doUnlockState();
  753.          this.nSmokeDelay = 0;
  754.          if(!this.bNeedToCrouch)
  755.          {
  756.             if(!this.bPepperReaction)
  757.             {
  758.                if(this.bGoingLeft)
  759.                {
  760.                   this.setState("SlowDown");
  761.                }
  762.                else if(this.bGoingRight)
  763.                {
  764.                   this.setState("Run");
  765.                }
  766.                else
  767.                {
  768.                   this.setState("CruiseControl");
  769.                }
  770.             }
  771.             else
  772.             {
  773.                this.setState("Run");
  774.             }
  775.          }
  776.          else
  777.          {
  778.             this.setState("CrouchRun");
  779.          }
  780.          this.doBoarSound();
  781.       }
  782.    }
  783.    function doLoadStateAction()
  784.    {
  785.       super.doLoadStateAction();
  786.       switch(this.sState)
  787.       {
  788.          case "FeatherCatch":
  789.             Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"Feather.mp3");
  790.             Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"Feather_Go.mp3");
  791.             break;
  792.          case "StunnedStart":
  793.             Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"Hurt.mp3",100,1,true);
  794.             this.bShouldMove = false;
  795.             break;
  796.          case "StunnedLoop":
  797.             this.oStunnedSound.doStop();
  798.             this.oStunnedSound.doDestroy();
  799.             delete this.oStunnedSound;
  800.             this.oStunnedSound = Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"Stunned.mp3",100,999,true);
  801.             this.oStunnedSound.doAddListener(this);
  802.             break;
  803.          case "StunnedEnd":
  804.             this.oStunnedSound.setFadeRate(15);
  805.             this.oStunnedSound.doFadeTo(0);
  806.             this.bShouldMove = true;
  807.             break;
  808.          case "CrouchRun":
  809.             this.bCrouched = true;
  810.             this.doBoarSound();
  811.             break;
  812.          case "JumpStart":
  813.             this.doLockState();
  814.             this.doBoarSound();
  815.             this.doSetSpeeds(undefined,- TakGround.JUMPSPEED,true);
  816.             Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"Jump.mp3");
  817.       }
  818.    }
  819.    function doUnLoadStateAction()
  820.    {
  821.       super.doUnLoadStateAction();
  822.       switch(this.sState)
  823.       {
  824.          case "CrouchIdle":
  825.          case "CrouchRun":
  826.             this.bCrouched = false;
  827.       }
  828.    }
  829. }
  830.